<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">

        //静态注册表单提交事务
        function onsubmitFun(){
            // 要验证所有表单项是否合法,如果有一个不合法，就阻止表单提交
            alert("静态注册表单提交事件---发现不合法");

            return false;
        }

        window.onload = function (){
            //1 获取标签对象
            var formObj = document.getElementById("form01");
            //2 通过标签对象.事件名 = function(){}
            formObj.onsubmit = function (){
                alert("动态注册表单提交事件---发现不合法");

                return false;
            }

        }
    </script>
</head>
<body>

    <form action="http://localhost:8080" method="get" onsubmit="return onsubmitFun();">
        <input type="submit" value="静态注册"/>
    </form>

    <form action="http://localhost:8080" method="get" id="form01">
        <input type="submit" value="动态注册"/>
    </form>
</body>
</html>